﻿
@{
    Layout = "~/Views/Shared/_LayuiLayout.cshtml";
}
@using lwzlz.Common
@model ButtonOutput

    <form class="layui-form layui-form-pane">
        @Html.AntiForgeryToken()
        <input type="hidden" name="Id" value="@Model.Id" />
        <input type="hidden" name="ParentId" value="@ViewBag.MenuId" />
        
        <div class="layui-form-item">
            <label class="layui-form-label">按钮名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="MenuName" value="@Model.MenuName" lay-verify="required" autocomplete="off" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">按钮方法</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="MenuAction" value="@Model.MenuAction" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">扩展方法</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="MenuMethod" value="@Model.MenuMethod" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">按钮位置</label>
            <div class="layui-input-block">
                <select name="BtnPosType">
                    @foreach (MenuPosType item in Enum.GetValues(typeof(MenuPosType)))
                    {
                        <option value="@((int)item)" @((int)item == Model.BtnPosType ? "selected=\"selected\"" : "")>@item.ToString()</option>
                    }
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">按钮图标</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="MenuIcon" value="@Model.MenuIcon" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">按钮样式</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="MenuCss" value="@Model.MenuCss" autocomplete="off" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">按钮排序</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="SortIndex" value="@Model.SortIndex" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" class="layui-input" title="启用" name="IsEnable" value="True" @(Model.IsEnable ? "checked=\"checked\"" : "") />
            </div>
        </div>

        <div class="layui-form-item" align="center">
            <button type="button" class="layui-btn" lay-submit="" lay-filter="Save">保存</button>
            <button type="button" class="layui-btn layui-btn-primary" id="btnCancel">取消</button>
        </div>
    </form>

@section scripts{
    <script type="text/javascript">
    var $, layer;
    layui.use(['form'], function () {
        var form = layui.form;
        $ = layui.jquery;
        layer = parent.layer === undefined ? layui.layer : parent.layer;

        // 监听关闭
        $('#btnCancel').on('click', function () {
            layer_close();
        });

        // 监听提交
        form.on('submit(Save)', function (data) {
            var loading = layer.load();
            $.post('@Url.Action("ButtonAddOrEdit", "Menu")', data.field,
                function (result) {
                    layer.close(loading);
                    if (result.Success) {
                        layer.msg(result.Message, { icon: 1, time: 2000 });
                        parent.reload();
                        layer_close();
                    } else {
                        layer.alert(result.Message, { icon: 2 });
                    }
                });
            return false;
        })
    });
    </script>
}


